//
//  NoteBuinessLogic.m
//  NoteDemo
//
//  Created by 郑火 on 16/2/17.
//  Copyright © 2016年 zwz. All rights reserved.
//

#import "NoteBuinessLogic.h"

@implementation NoteBuinessLogic
//插入Note
-(void) createNote:(Note*)model
{
    NoteDAO* dao = [NoteDAO sharedManager];
    dao.delegate = self;
    [dao create:model];
}

//删除Note
-(void) deleteNote:(Note*)model
{
    NoteDAO* dao = [NoteDAO sharedManager];
    dao.delegate = self;
    [dao remove:model];
}

//查询所有Note
-(void) findAllNotes
{
    NoteDAO* dao = [NoteDAO sharedManager];
    dao.delegate = self;
    [dao findAll];
}


//修改Note
-(void) modifyNote:(Note*)model
{
    NoteDAO* dao = [NoteDAO sharedManager];
    dao.delegate = self;
    [dao modify:model];
}

#pragma --mark NoteDAODelegate 委托方法
//查询所有数据方法 成功
- (void)findAllFinished:(NSMutableArray *)list
{
    [self.delegate findAllNotesFinished:list];
}

//查询所有数据方法 失败
- (void)findAllFailed:(NSError *)error
{
    [self.delegate findAllNotesFailed:error];
}

//插入Note方法 成功
- (void)createFinished
{
    [self.delegate createNoteFinished];
}

//插入Note方法 失败
- (void)createFailed:(NSError *)error
{
    [self.delegate createNoteFailed:error];
}

//删除Note方法 成功
- (void)deleteFinished
{
    [self.delegate deleteNoteFinished];
}
//删除Note方法 失败
- (void)deleteFailed:(NSError *)error
{
    [self.delegate deleteNoteFailed:error];
}
//修改Note方法 成功
- (void)modifyFinished
{
    [self.delegate modifyNoteFinished];
}

//修改Note方法 失败
- (void)modifyFailed:(NSError *)error
{
    [self.delegate modifyNoteFailed:error];
}
@end
